package com.zut.edu.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import com.zut.edu.R;
import com.zut.edu.bean.Data;
import com.zut.edu.widget.ListViewAdapter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class RecordFragment extends Fragment {

    private ListView listView;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_record, container, false);
        return view;
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        listView = getView().findViewById(R.id.fragment_record_listview);
        initlist();
    }
    public void initlist(){
        Data data1 = new Data("food","111","2021/3/18");
        Data data2 = new Data("water","222","2021/3/18");
        Data data3 = new Data("findViewById","222","2021/3/18");
        Data data4 = new Data("created","222","2021/3/18");
        Data data5 = new Data("water","222","2021/3/18");
        Data data6 = new Data("water","222","2021/3/18");
        Data data7 = new Data("getView","222","2021/3/18");
        Data data8 = new Data("water","222","2021/3/18");
        Data data9 = new Data("water","222","2021/3/18");
        List<Data> list = new ArrayList<>(Arrays.asList(data1,data2,data3,data4,data5,data6,data7,data8,data9));
        ListViewAdapter listViewAdapter = new ListViewAdapter(getContext(),list);
        listView.setAdapter(listViewAdapter);
    }
}
